package com.dxl.utils;

import com.dxl.entity.ResponseData;
import com.dxl.enums.ResultEnums;

public class ResDataUtil {
    /**
     * 带实体的统一返回
     *
     * @param data 实体
     * @param <T>  实体类型
     * @return
     */
    public static <T> ResponseData success(String code, String msg, T data) {
        return new ResponseData<T>(true,code, msg, data);
    }

    public static <T> ResponseData success(ResultEnums resultEnums, T data) {
        return new ResponseData<T>(true,resultEnums, data);
    }

    public static <T> ResponseData success(String msg, T data) {
        return new ResponseData<T>(true,"0", msg,  data);
    }

    public static <T> ResponseData success(T data) {
        return new ResponseData<T>(true,"0", "请求成功",  data);
    }

    public static ResponseData success(String msg) {
        return new ResponseData(true, "0", msg, null);
    }


    public static <T> ResponseData failure(String code, String msg, T data) {
        return new ResponseData<T>(false,code, msg,  data);
    }

    public static <T> ResponseData failure(ResultEnums resultEnums, T data) {
        return new ResponseData<T>(false,resultEnums,  data);
    }

    public static ResponseData failure(ResultEnums resultEnums) {
        return new ResponseData(false,resultEnums,  null);
    }

    public static ResponseData failure(String code, String msg) {
        return new ResponseData(false,code, msg,null);
    }

    public static ResponseData failure(String msg) {
        return new ResponseData(false,"1", msg,  null);
    }
}



